﻿Public Class frmEscolhaTipoDroga
    Inherits formPadrao

    Public ehMaconha As Boolean = Nothing
    Public ehCocaina As Boolean = Nothing
    Public ehEcstasy As Boolean = Nothing
    Public ehCrack As Boolean = Nothing
    Public CARREGADADOS As Boolean = Nothing
    Public NUM_REGISTRO As Integer
    Public ANO As Integer
    Public ID_TIPO_PERICIA As Integer
    Public ID_NATUREZA As Integer
    Public EHPRELIMINAR As Boolean = Nothing
    Public EHNOVO As Boolean = True
    Public habilitaBotao As Boolean = True

   

    Private Sub btnCocaina_Click(sender As Object, e As EventArgs) Handles btnCocaina.Click, btnCrack.Click, btnEcstasy.Click, btnMaconha.Click


        Dim form As New frmMaconha
        form.ucPreambulo.CARREGADADOS = False
        form.ucPreambulo.txtLaudo.Text = NUM_REGISTRO
        form.ucPreambulo.ID_TIPO_PERICIA = ID_TIPO_PERICIA
        form.ucPreambulo.getAno = ANO
        form.ucPreambulo.ID_NATUREZA = ID_NATUREZA
        form.ucPreambulo.ehNovo = EHNOVO
        

        Select Case CType(sender, Button).Text.ToUpper

            Case "CRACK"
                form.ehMaconha = False
                form.ehCocaina = False
                form.ehEcstasy = False
                form.ehCrack = True
            Case "MACONHA"
                form.ehMaconha = True
                form.ehCocaina = False
                form.ehEcstasy = False
                form.ehCrack = False
            Case "COCAÍNA"
                form.ehMaconha = False
                form.ehCocaina = True
                form.ehEcstasy = False
                form.ehCrack = False
            Case "ECSTASY"
                form.ehMaconha = False
                form.ehCocaina = False
                form.ehEcstasy = True
                form.ehCrack = False

        End Select

        'Dim formPai As frmPrincipal
        '' form.MdiParent = Me.ParentForm
        form.MdiParent = Me.ParentForm
        form.EHPRELIMINAR = True
        form.Show()
        form.chamaEventoBuscaLaudo(sender, e)

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnConstatacaoPreliminar.Click
        Try
            Dim form As New frmConstatacaoPreliminar(False)
            form.ucPreambulo.CARREGADADOS = False
            form.EHPRELIMINAR = True
            form.ucPreambulo.txtLaudo.Text = NUM_REGISTRO
            form.ucPreambulo.ID_TIPO_PERICIA = ID_TIPO_PERICIA
            form.ucPreambulo.getAno = ANO
            form.ucPreambulo.ID_NATUREZA = ID_NATUREZA
            form.ucPreambulo.ehNovo = EHNOVO
            generica.fechaForms(Me)
            form.MdiParent = Me.ParentForm
            form.Show()
            form.chamaEventoBuscaLaudo(sender, e)

        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles btnDefinitivo.Click
        Try

            Dim form As New frmDefinitivo
            form.ucPreambulo.CARREGADADOS = False
            form.EHPRELIMINAR = False
            form.ucPreambulo.txtLaudo.Text = NUM_REGISTRO
            form.ucPreambulo.ID_TIPO_PERICIA = ID_TIPO_PERICIA
            form.ucPreambulo.getAno = ANO
            form.ucPreambulo.ID_NATUREZA = ID_NATUREZA
            form.ucPreambulo.ehNovo = EHNOVO
            generica.fechaForms(Me)
            form.MdiParent = Me.ParentForm
            form.Show()
            form.chamaEventoBuscaLaudo(sender, e)

        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles btnDefTco.Click
        Try
            Dim form As New frmConstatacaoPreliminar(True)
            form.ucPreambulo.CARREGADADOS = False
            form.EHPRELIMINAR = False
            form.ucPreambulo.txtLaudo.Text = NUM_REGISTRO
            form.ucPreambulo.ID_TIPO_PERICIA = ID_TIPO_PERICIA
            form.ucPreambulo.getAno = ANO
            form.ucPreambulo.ID_NATUREZA = ID_NATUREZA
            form.ucPreambulo.getIdNatureza = ID_NATUREZA
            form.ucPreambulo.ehNovo = EHNOVO
            generica.fechaForms(Me)
            form.MdiParent = Me.ParentForm
            form.Show()
            form.chamaEventoBuscaLaudo(sender, e)

        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub

    Private Sub frmEscolhaTipoDroga_Load(sender As Object, e As EventArgs) Handles Me.Load

        Select Case ID_NATUREZA
            Case 68 'PRELIMINAR
                habilitaBotao = True
            Case 73 ' DEFINITIVO
                habilitaBotao = False
        End Select
        btnCocaina.Enabled = habilitaBotao
        btnMaconha.Enabled = habilitaBotao
        btnCrack.Enabled = habilitaBotao
        btnEcstasy.Enabled = habilitaBotao
        btnConstatacaoPreliminar.Enabled = habilitaBotao
        btnDefinitivo.Enabled = Not habilitaBotao
        btnDefTco.Enabled = False

        'Select Case ID_NATUREZA
        '    Case 68 'PRELIMINAR
        '        habilitaBotao = True
        '    Case 73 ' DEFINITIVO
        '        habilitaBotao = False
        'End Select
        'btnCocaina.Enabled = habilitaBotao
        'btnMaconha.Enabled = habilitaBotao
        'btnCrack.Enabled = habilitaBotao
        'btnEcstasy.Enabled = habilitaBotao
        'btnConstatacaoPreliminar.Enabled = False
        'btnDefinitivo.Enabled = True
        'btnDefTco.Enabled = False



    End Sub
End Class